package main

import (
	"fmt"

	"github.com/spf13/viper"
)

var ServerConf = new(ServerConfig)

func InitConfig(path string) error {
	viper.SetConfigFile(path)

	err := viper.ReadInConfig()
	if err != nil {
		fmt.Printf("viper.ReadInConfig failed, err:%v\n", err)
		return err
	}

	if err := viper.Unmarshal(ServerConf); err != nil {
		fmt.Printf("viper.Unmarshal failed, err:%v\n", err)
		return err
	}
	return nil
}
